<?php

namespace common\models\feedback;

use Yii;

/**
 * This is the model class for table "{{%feedback_scene}}".
 *
 * @property int $id
 * @property int $parent_id
 * @property string $name 场景或问题名称
 * @property string $description 说明描述
 * @property int $listorder 显示排序
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class FeedbackScene extends \common\db\ActiveRecord {

    /**
     * 默认状态
     */
    const STATUS_DELETED = 0;

    /**
     * 激活状态
     */
    const STATUS_ACTIVE = 10;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%feedback_scene}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['parent_id', 'listorder', 'status', 'created_at', 'updated_at'], 'integer'],
            [['name'], 'required'],
            [['name'], 'string', 'max' => 50],
            [['description'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'parent_id' => 'Parent ID',
            'name' => '场景或问题名称',
            'description' => '说明描述',
            'listorder' => '显示排序',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

    public function getChildren() {
        return $this->hasMany(static::className(), ['id' => 'parent_id']);
    }

}
